package com.azier.kapacitor.script.node;

import com.azier.kapacitor.script.method.*;
import com.azier.kapacitor.script.node.nodebind.CombineNodeBind;

import java.util.ArrayList;

/**
* 1 * @Author: luoj
* 2 * @Date: 2019/11/8 11:27
* 3
*/

/**
Flatten points with similar times into a single point.
**/
/**
将具有相似时间的点展平为单个点。
**/
public class FlattenNode extends AbstractNode implements CombineNodeBind {
    private static final String name = "flatten";

    public FlattenNode() {
        super(new ArrayList<>(),new ArrayList<>(),name);
    }

    /**
    The delimiter between field name parts
    **/
    /**
    字段名称部分之间的分隔符
    **/
    public FlattenNode delimiter(String flatten){
        Delimiter delimiter = new Delimiter(flatten);
        super.addMethod(delimiter);
        return this;
    }
    /**
    DropOriginalFieldName indicates whether the original field name should be dropped when constructing the final field name.
    **/
    /**
    DropOriginalFieldName指示在构造最终字段名称时是否应删除原始字段名称。
    **/
    public FlattenNode dropOriginalFieldName(boolean ...drop){
        DropOriginalFieldName dropOriginalFieldName = new DropOriginalFieldName(drop);
        super.addMethod(dropOriginalFieldName);
        return this;
    }
    /**
    Specify the dimensions on which to flatten the points.
    **/
    /**
    指定展平点的尺寸。
    **/
    public FlattenNode on(String ...dims){
        On on = new On(dims);
        super.addMethod(on);
        return this;
    }
    /**
    Suppress all error logging events from this node.
    **/
    /**
    禁止来自此节点的所有错误记录事件。
    **/
    public FlattenNode quiet(){
        Quiet quiet = new Quiet();
        super.addMethod(quiet);
        return this;
    }
    /**
    The maximum duration of time that two incoming points can be apart and still be considered to be equal in time. The joined data point’s time will be rounded to the nearest multiple of the tolerance duration.
    **/
    /**
    两个进入点可以分开并且仍然被认为在时间上相等的最大持续时间。加入的数据点的时间将四舍五入到公差持续时间的最接近倍数。
    **/
    public FlattenNode tolerance(long interval, String durationLiteral){
        Tolerance tolerance = new Tolerance(interval, durationLiteral);
        super.addMethod(tolerance);
        return this;
    }
}